home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / mac / Alati / GrafiËka pomagala / clip2gif 0.7.2.1 / Calling clip2gif from C / example-appl.c < prev    next >
C/C++ Source or Header  |  1995-12-11  |  1KB  |  61 lines

  1. /*
  2.  *    Demo of using clip2gif with the CFM PPC
  3.  *
  4.  *    This program grabs a bit of screen and saves it in a GIF file
  5.  *
  6.  *    To compile it, create a new PPC project with CW7 (other versions and compilers
  7.  *    might also work, but haven't been tested), include example.c, LoadClip2Gif.c
  8.  *    and the standard MacOS libraries, and build it. clip2gif should be in the same disk.
  9.  *
  10.  *    Caution:    This program calls a low-level debugger if it gets an error. Remove DebugStr
  11.  *                if you don't have one to avoid having to restart. Neither clip2gif nor the
  12.  *                CFM glue stuff call the debugger.
  13.  *
  14.  *    Copyright 1995, Yves Piguet. All rights reserved.
  15.  */
  16.  
  17. #include "LoadClip2Gif.h"
  18.  
  19. static void InitToolbox()
  20. {
  21.     InitGraf((Ptr)&qd.thePort);
  22.     InitFonts();
  23.     InitWindows();
  24.     InitMenus();
  25.     TEInit();
  26.     InitDialogs(0L);
  27.     InitCursor();
  28. }
  29.  
  30. void main(void)
  31. {
  32.     Rect r;
  33.     PicHandle thePic;
  34.     OSErr err;
  35.     StandardFileReply fileReply;
  36.     
  37.     InitToolbox();
  38.     
  39.     if (LoadClip2Gif() != noErr)
  40.     {
  41.         DebugStr("\pCannot load clip2gif");
  42.         ExitToShell();
  43.     }
  44.     
  45.     StandardPutFile("\pSave screen bit as", "\pscreen.gif", &fileReply);
  46.     if (fileReply.sfGood)
  47.     {
  48.         SetRect(&r, 0, 0, 200, 160);
  49.         err = GetScreen(&r, &thePic);
  50.         if (err != noErr)
  51.             DebugStr("\pGetScreen error.");
  52.         else
  53.         {
  54.             err = ConvertPictToGIFFile(thePic, &fileReply.sfFile,
  55.                         1, transparencyNo, 8, colorPaletteSystem);
  56.             if (err != noErr)
  57.                 DebugStr("\pConvertPictToGifFile error.");
  58.         }
  59.     }
  60. }
  61.